//package com.bjtu.douyin.config;
//
//import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
//import com.alibaba.cloud.nacos.NacosServiceManager;
//import com.alibaba.nacos.api.exception.NacosException;
//import com.alibaba.nacos.api.naming.NamingService;
//import com.alibaba.nacos.api.naming.pojo.Instance;
//import com.bjtu.douyin.utils.video.GrpcClient;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.util.List;
//
//@Configuration
//public class GrpcClientConfig {
//
//    @Autowired
//    private NacosServiceManager nacosServiceManager;
//
//    @Autowired
//    private NacosDiscoveryProperties nacosDiscoveryProperties;
//
//    @Bean
//    public GrpcClient grpcClient() throws NacosException {
//        NamingService namingService = nacosServiceManager.getNamingService(nacosDiscoveryProperties.getNacosProperties());
//        List<Instance> allInstances = namingService.getAllInstances("api-recommend");
//        String ip = allInstances.get(0).getIp();
//        Integer port = allInstances.get(0).getPort();
//        System.out.println(ip);
//        System.out.println(port);
//        return new GrpcClient(ip, port);
////        return new GrpcClient("58.87.105.2", 50051);
//    }
//}
